package com.spring.hotel.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.spring.hotel.common.JsonResponse;
import com.spring.hotel.entity.Employee;
import com.spring.hotel.entity.PageDTO;
import com.spring.hotel.mapper.EmployeeMapper;
import org.springframework.stereotype.Service;

@Service
public class EmployeeService extends ServiceImpl<EmployeeMapper, Employee> {
    //分页展示
    public JsonResponse pageList(Employee employee, PageDTO pageDTO) {
        QueryWrapper<Employee> queryWrapper = new QueryWrapper<>();
        if (employee.getId() != null) {
            queryWrapper.lambda().like(Employee::getId, employee.getId());
        }
        Page<Employee> page = this.page(new Page<>(pageDTO.getPageNum(), pageDTO.getPageSize()), queryWrapper);
        return JsonResponse.success(page);
    }
}